<template>
  <div class="pagss">
    <div style="height: 20px;"></div>
    <Navvz></Navvz>

    <el-row>


      <el-col :span="24">
        <div class="panel-group1">
          <div class="f_24 f_bold ml_20 mb_10">充值记录</div>
          <el-form :model="queryParams" ref="queryForm" label-width="100px" class="demo-ruleForm">

            <div class="row ">
              <el-form-item class="itembox box2" label="订单编号："><el-input placeholder="请输入订单编号" v-model="queryParams.filter.order_number"></el-input></el-form-item>

              <el-form-item class="itembox" label="姓名："><el-input placeholder="请输入姓名" v-model="queryParams.filter.account"></el-input></el-form-item>

              <el-form-item label="状态:" class="itembox">
                <el-select v-model="queryParams.filter.recharge_state" placeholder="请选择">
                  <el-option label="待充值" value="0"></el-option>
                  <el-option label="充值成功" value="1"></el-option>
                  <el-option label="充值失败" value="2"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="区服:" class="itembox">
                <el-select v-model="queryParams.filter.area" placeholder="请选择">
                    <el-option v-for="(item,index) of filter_area" :key="index" :label="item.label" :value="item.value"></el-option>
                </el-select>
              </el-form-item>
              
            </div>

            <div class="row mb_20">
              <el-form-item label="订单时间：" class="itembox">
                <el-date-picker v-model="queryParams.filter.time" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd"></el-date-picker>
              </el-form-item>
              <el-button style="height: 36px;width: 86px;" type="primary" @click="handleQuery">查询</el-button>
              <el-button style="height: 36px;width: 86px;" @click="resetQuery">清空</el-button>
            </div>
          </el-form>

          <el-table :data="tableData" style="width: 100%" :row-class-name="tableRowClassName" v-loading="loading">
            <el-table-column prop="order_number" align="center" label="订单编号" width="220"></el-table-column>
            <el-table-column prop="areaTitle" align="center" label="区服" width="180"></el-table-column>
            <el-table-column prop="role" align="center" label="角色"></el-table-column>
            <el-table-column prop="recharge_amount" align="center" label="充值金额"></el-table-column>
            <el-table-column prop="channeTitle" align="center" label="充值渠道"></el-table-column>
            <el-table-column prop="payment_time" align="center" label="充值时间"></el-table-column>
            <!-- <el-table-column prop="recharge_state" align="center" label="状态"></el-table-column> -->


            <el-table-column label="状态" align="recharge_state" prop="condition">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.recharge_state==0" class="ml-2" type="info">待充值</el-tag>
                <el-tag v-if="scope.row.recharge_state==1" class="ml-2" type="danger">充值成功</el-tag>
                <el-tag v-if="scope.row.recharge_state==2" class="ml-2" type="success">充值失败</el-tag>
              </template>
            </el-table-column>

            <el-table-column prop="account" align="center" label="姓名"></el-table-column>
            <el-table-column prop="phone" align="center" label="手机号"></el-table-column>
          </el-table>


          <div class="center ">
            <pagination v-show="total>0" :total="total" :page.sync="queryParams.noPage" :limit.sync="queryParams.pageSize" @pagination="getList" />
          </div>


        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import CountTo from 'vue-count-to';
  import Cookies from 'js-cookie';
  import Vue from 'vue';
  import Navvz from '@/components/Navvz';
  import Sidebartss from '@/components/Sidebartss';
  import * as Recharge from '@/api/system/recharge';

  export default {
    name: 'Index',
    components: {
      CountTo,
      Navvz,
      Sidebartss
    },
    data() {
      return {
        user_id: '',
        loading: false,


        time_value: '',

        ruleForm: {
          business_type: '',
          name: '',
          account_number: '',
          work_number: '',
          handling_person: '',
          form_state: ''
        },
        // 总条数
        total: 0,
        // 查询参数
        queryParams: {
          noPage: 1,
          pageSize: 10,
          filter: {
            order_number: null,
            account: null,
            recharge_state: null,
            area: null,
            time: null,

          },
        },
        tableData: [],
        filter_area: [],
        rules: {}
      };
    },
    created() {
      // 读取缓存
      this.userId = localStorage.getItem('user_id');
      this.getList();
    },
    mounted() {},
    methods: {

      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.noPage = 1;
        this.getList();
      },

      /** 重置按钮操作 */
      resetQuery() {
        this.queryParams.filter.order_number = null;
        this.queryParams.filter.account = null;
        this.queryParams.filter.recharge_state = null;
        this.queryParams.filter.area = null;
        this.queryParams.filter.time = null;
        this.handleQuery();
      },

      /** 查询列表 */
      getList() {
        console.log('aaa', this.queryParams);
        this.queryParams.user = this.userId
        this.queryParams.type_pj = 1

        this.loading = true;
        Recharge.getList(this.queryParams).then(response => {
          this.tableData = response.data.list;
          this.filter_area = response.data.filter_area;
          this.total = response.data.pagination.totalCount;
          this.loading = false;

        });
      },


      tableRowClassName({ row, rowIndex }) {
        if (rowIndex === 1) {
          return 'warning-row';
        } else if (rowIndex === 3) {
          return 'success-row';
        }
        return '';
      },

      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
      },

      gotoPage(url) {
        this.$router.push(url);
      }
    }
  };
</script>

<style lang="scss" scoped>
  .pagss {
    height: 100%;
    background: #e4eef9;
    // padding: 5px 0 15px 40px;
  }

  .panel-group1 {
    padding: 25px;
    margin-top: 18px;
    margin-bottom: 0px;
    margin-right: 15px;
    margin-left: 15px;
    min-height: 760px;
    background: #ffffff;
    border-radius: 10px 10px 10px 10px;
    opacity: 1;
  }

  .itembox {
    margin-right: 45px;
    // width: 170px;
    // height: 64px;
  }

  ::v-deep .el-input--medium .el-input__inner {
    // height: 32px;
    // width: 170px;
    width: 100%;
  }

  .box2 {
    ::v-deep .el-input--medium .el-input__inner {
      // height: 32px;
      // width: 170px;
      width: 107%;
    }
  }

  ::v-deep .el-button--primary {
    color: #FFFFFF;
    background-color: #3FC1C9 !important;
    border-color: #3FC1C9 !important;
  }

  ::v-deep .el-button:hover,
  .el-button:focus {
    color: #000000;
    border-color: #A5EDF1;
    background-color: #A5EDF1;
  }

  ::v-deep .el-table .el-table__header-wrapper th,
  .el-table .el-table__fixed-header-wrapper th {
    // background-color: #F8F8F8;
  }
</style>
